package com.financial.business.balance.controller;

import com.financial.business.balance.service.FinancialBalancePayService;
import com.financial.business.balance.service.FinancialBalancePaymentService;
import com.financial.business.balance.service.FinancialBalanceQueryService;
import com.financial.business.balance.service.FinancialBalanceRefundService;
import com.financial.business.balance.utils.apiresult.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @api {post} /business/balance
 * @apiExample author WANGNING
 * tar 余额支付业务
 * date 2019年10月29日
 * @apiGroup balance-business
 * @apiVersion 1.0.0
 * @apiHeader {String} null 无
 * @apiParam {String} null 无
 * @apiSuccess {String} succeed 就绪
 */
@RestController
@RequestMapping("/balance")
public class FinancialBalanceController {
    @Autowired
    private FinancialBalancePayService financialBalancePayService;

    @Autowired
    private FinancialBalanceRefundService financialBalanceRefundService;

    @Autowired
    private FinancialBalancePaymentService financialBalancePaymentService;

    @Autowired
    private FinancialBalanceQueryService financialBalanceQueryService;

    /**
     * 余额支付
     *
     * @param requestParam
     * @return
     */
    @RequestMapping(value = {"/pay"}, method = {RequestMethod.POST})
    @ResponseBody
    public ApiResult pay(@RequestBody String requestParam) {

        return financialBalancePayService.pay(requestParam);
    }

    /**
     * 余额退款
     *
     * @param requestParam
     * @return
     */
    @RequestMapping(value = {"/refund"}, method = {RequestMethod.POST})
    @ResponseBody
    public ApiResult refund(@RequestBody String requestParam) {

        return financialBalanceRefundService.refund(requestParam);
    }

    /**
     * 余额代付/转账
     *
     * @param requestParam
     * @return
     */
    @RequestMapping(value = {"/payment"}, method = {RequestMethod.POST})
    @ResponseBody
    public ApiResult payment(@RequestBody String requestParam) {

        return financialBalancePaymentService.payment(requestParam);
    }

    /**
     * 余额所有查询
     *
     * @param requestParam
     * @return
     */
    @RequestMapping(value = {"/query"}, method = {RequestMethod.POST})
    @ResponseBody
    public ApiResult query(@RequestBody String requestParam) {

        return financialBalanceQueryService.query(requestParam);
    }
}
